<?php

class Application_Model_DbTable_wayBillItem extends Application_Model_DbTable_DomainObject {

    protected $_name = 'uuch_waybill';

	public function getMapper(){
		return array('id','billNo','dateCreated','dateSend','stockDate','dateUserConfrim','discountFee',
                    'serviceFee','shipFee','status','useScore','userId','shipType','shipFeeconfig','shipMoney','consignee',
                    'conAdd','conTel','conPostCode','bagWeight','weight','logistics', 'comment','lastdate','volumeWeight','productWeight',
                    'lastWeight','state','isNoLogo','isNoSkin','isCompress','reportFee','lastMoney','costMoney','agentNo','agentId',
                    'refundMoney','lastVolumeWeight','expressCostId','isVolume','channer','expressId','remark','interior','problem','isWooden','datePaid','paymentWeight','isInvoice','isAddform','dutyNo',"interiorRemark");
	}
    
    /*
     * 根据用户序号获取信息
     */

    public function getByUser($userId, $state, $start, $row) {

        $db = $this->getAdapter();
        $filter = $db->quoteInto(' userId = ?', $userId);
        if ($state != -1) {
            $filter = $db->quoteInto(' status = ?', $state);
        }
        $rows = $this->fetchAll($filter, 'id', $row, $start);

        $result = array();
        foreach ($rows as $row)
            array_push($result, $this->convertRowToObject($row));
        return $result;
    }

    /*
     * 根据用户名，状态获取当前总数
     * @param int $userid 用户序号
     * @param int $status 用户序号
     * @return int
     */

    public function getItemCount($user, $status) {

        $db = $this->getAdapter();

        if ($status == -1) {
            $result = $db->query('select count(*) from uuch_waybill where userid=' . $user);
        } else {
            $result = $db->query('select count(*) from uuch_waybill where userid=' . $user . ' and status=' . $status);
        }
        $c = $result->fetchColumn();
        return $c;
    }

}